(function($, undefined){

    $.fn.sharebox = function (options){
        var name='Sharebox',
            isMethodCall = typeof options === "string",
            args = Array.prototype.slice.call(arguments, 1),
            returnValue = this;

        options = !isMethodCall && args.length ?
            $.extend.apply(null, [true, options].concat(args)) : options;

        if(isMethodCall && options.charAt(0)==="_"){
            return returnValue;
        }

        if(isMethodCall){
            this.each(function(){
                var instance = $data(this, name),
                    methodValue = instance && $.isFunction(instance[options]) ?
                        instance[options].apply(instance, args) : instance;
                if(methodValue !== instance && methodValue !== undefined){
                    returnValue = methodValue;
                    return false;
                }
            });
        } else{
            this.each(function(){
                var instance = $.data(this, name);
                if(instance){
                    instance.option(options || {});
                } else{
                    $.data(this, name, new $.sharebox(options, this));
                }
            });
        }

        return returnValue;
    };

    $.sharebox = function(options, element){
        var that = this;
        if(arguments.length){
            this.element = $(element);
            this.options = $.extend(true, {}, this.options, options);
            this.element.bind('remove.share', function(){
                that.destroy();
            });
            this._init();
        }
    };

    $.stream.event = {
        sharepost : 'when an item is posted'
    };

    $.sharebox.prototype = {
        sharebox_template : '@sharebox.mu@',

        options: {
            offset : null
        },

        _init: function(){
            this._initRender();
            this._initBind();
        },

        destroy: function(){},

        _initRender: function() {
            var offset = this.options.offset,
                beforeItem;
            if(!offset){
                return;
            }
            beforeItem = this.element.find('.item-box')[offset];
            beforeItem.after(this.sharebox_template).show(4000);
        },

        _initBind: function(){
            this._bindHandler = this.element.delegate('.sharebox-clickable', 'click', this._onClickHandle);
        },

        _onClickHandle: function(e) {
            var curTarget = e.currentTarget;
			if(curTarget.hasClass('submit-btn')){
				//this._zoomDetail();
			} else if(curTarget.hasClass('close-box')){
				//this._showCommentsList();
			}
        }
    };
})(jQuery);
